package com.example.actearly_revised;

import java.util.ArrayList;

public class QuestionAnswerGroup {
	
	private final String yes_ans = "yes";
	private final String no_ans = "no";
	private final String maybe_ans = "notsure";	
	
	private String Question;
	private String Answer;   
	private String Category;
	private int Urgency;
	private int QuestionId;
	private int childId;
	
	// 3 constructors to create a QuestionAnswerGroup
	public QuestionAnswerGroup(String Question, String Answer, 
			String Category, int Urgency, int QuestionId, int childId){
		
		this.Question = Question;
		this.Answer = Answer;
		this.Category = Category;
		this.Urgency = Urgency;
		this.QuestionId = QuestionId;
		this.childId = childId;
	}
	
	public QuestionAnswerGroup(String Question, String Answer, 
			String Category, int Urgency, int QuestionId){
		
		this.Question = Question;
		this.Answer = Answer;
		this.Category = Category;
		this.Urgency = Urgency;
		this.QuestionId = QuestionId;
		
	}
	
	public QuestionAnswerGroup(String Question, String Category, int Urgency, int QuestionId,int childId){
		
		this.Question = Question;
		this.Answer = null;
		this.Category = Category;
		this.Urgency = Urgency;
		this.QuestionId = QuestionId;
	}
	
	// Methods to get needed pieces from QuestionAnswerGroup
	public String getQuestion(){
		return this.Question;
	}
	
	public String getAnswer(){
		return this.Answer;
	}
	
	public String getCategory(){
		return this.Category;
	}
	
	public int getUrgency(){
		return this.Urgency;
	}
	
	public int getQuestionId(){
		return this.QuestionId;
	}
	
		
	// works to find where in the arraylist a certian question ID is and if its in the list
	public static int indexOf(int QuestionId, ArrayList<QuestionAnswerGroup> list){
		for(int i = 0; i < list.size(); i++){
			if(list.get(i).QuestionId == QuestionId){
				return i;
			}
		}
		return -1;
	}
	
	// debugging methods
	public static ArrayList<Integer> getAllQuestionIds(ArrayList<QuestionAnswerGroup> list){
		ArrayList<Integer> Qids =  new ArrayList<Integer>();
		for(int i = 0; i < list.size(); i++){
			Qids.add(list.get(i).getQuestionId());
		}
		return Qids;
	}
	
	public static ArrayList<Integer> testchildIds(ArrayList<QuestionAnswerGroup> list){
		ArrayList<Integer> ids = new ArrayList<Integer>();
		for(int i = 0; i < list.size(); i++){
			if(!ids.contains(list.get(i).childId)){
				ids.add(list.get(i).childId);
			}
		}
		return ids;
	}
	
	public static ArrayList<String> testAnswers(ArrayList<QuestionAnswerGroup> list){
		ArrayList<String> ans = new ArrayList<String>();
		for(int i = 0; i < list.size(); i++){
			if(!ans.contains(list.get(i).Answer)){
				ans.add(list.get(i).Answer);
			}
		}
		return ans;
	}
}
